package com.fenghongzhang.day007.search;

import android.database.sqlite.SQLiteDatabase;

import com.fenghongzhang.day007.App;


public class DaoManager {

    private DaoSession daoSession;

    private DaoManager(){
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(App.context, "search");
        SQLiteDatabase readableDatabase = devOpenHelper.getReadableDatabase();
        DaoMaster daoMaster = new DaoMaster(readableDatabase);
        daoSession = daoMaster.newSession();
    }
    private static DaoManager daoManager;

    public static DaoManager getInstance() {
        if(daoManager == null){
            synchronized (DaoManager.class){
                if(daoManager == null){
                    daoManager = new DaoManager();
                }
            }
        }
        return daoManager;
    }

    public SearchDao getSearchDao(){
        return daoSession.getSearchDao();
    }
}
